package com.wonders.hisdoctor.station.util;

import com.wonders.his.common.utils.DateUtils;
import com.wonders.hisdoctor.station.project.base.domain.ClinicMaster;
import com.wonders.hisdoctor.station.project.base.domain.OutpMr;
import com.wonders.hisdoctor.station.project.medicine.vo.PrintVo;
import com.wonders.hisdoctor.station.project.medicine.vo.TransfusionVo;
import com.wonders.hisdoctor.station.project.record.vo.OutpMrPrintVo;
import com.wonders.hisdoctor.station.project.record.vo.OutpMrVo;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;

/**
 * Description:
 *
 * @author tong-aj
 * <p>
 * Create: 2021-01-22 15:58
 */
public class ConvertUtils {

    private ConvertUtils(){}

    /**
    * Description: outpMrVo 转化为OutpMr
    * Param: [outpMrVo]
    * return: com.wonders.hisdoctor.station.project.base.domain.OutpMr
    * Author: tongaijie
    * Date: 2021/1/29
    */
    public static OutpMr convertToOutpMr(OutpMrVo outpMrVo){
        OutpMr outpMr = new OutpMr();
        BeanUtils.copyProperties(outpMrVo,outpMr);
        outpMr.setMrCreateDate(DateUtils.dateFormatDate(DateUtils.YYYY_MM_DD,new Date()));
        return outpMr;
    }

    /**
    * Description: OutpMr 转化为outpMrVo
    * Param: [outpMr]
    * return: com.wonders.hisdoctor.station.project.record.vo.OutpMrVo
    * Author: tongaijie
    * Date: 2021/1/29
    */
    public static OutpMrVo convertToOutpMrVo(OutpMr outpMr){
        OutpMrVo outpMrVo = new OutpMrVo();
        BeanUtils.copyProperties(outpMr,outpMrVo);
        return outpMrVo;
    }

    public static PrintVo convertClinicMasterToPrintVO(PrintVo printVo,ClinicMaster clinicMaster) {
        printVo.setCostType(clinicMaster.getChargeType());
        printVo.setPatientId(clinicMaster.getPatientId());
        printVo.setPatName(clinicMaster.getName());
        printVo.setPatSex(clinicMaster.getSex());
        printVo.setIdentity(clinicMaster.getIdentity());
        return printVo;
    }
    public static TransfusionVo convertClinicMasterToTransfusionVo(TransfusionVo transfusionVo, ClinicMaster clinicMaster) {
        transfusionVo.setCostType(clinicMaster.getChargeType());
        transfusionVo.setPatientId(clinicMaster.getPatientId());
        transfusionVo.setPatName(clinicMaster.getName());
        transfusionVo.setPatSex(clinicMaster.getSex());
        transfusionVo.setIdentity(clinicMaster.getIdentity());
        return transfusionVo;
    }

    public static PrintVo convertOutpMrToPrintVO(PrintVo printVo,OutpMr outpMr) {
        printVo.setDiagnosis(outpMr.getDiagDesc());
        return printVo;
    }

    public static OutpMrPrintVo convertClinicMasterToOutpMrPrintVo(OutpMrPrintVo printVo, ClinicMaster clinicMaster) {
        printVo.setCostType(clinicMaster.getChargeType());
        printVo.setPatientId(clinicMaster.getPatientId());
        printVo.setPatName(clinicMaster.getName());
        printVo.setPatSex(clinicMaster.getSex());
        printVo.setPatAge(clinicMaster.getAge().toString());
        printVo.setTime(clinicMaster.getVisitTimeDesc());
        return printVo;
    }

    public static OutpMrPrintVo convertOutpMrToOutpMrPrintVo(OutpMrPrintVo printVo,OutpMr outpMr) {
        printVo.setDiagnosis(outpMr.getDiagDesc());
        printVo.setSay(outpMr.getIllnessDesc());
        printVo.setMedicalHistory(outpMr.getMedHistory());
        printVo.setPhysical(outpMr.getBodyExam());
        printVo.setDisposition(outpMr.getAdvice());
        printVo.setExamination(outpMr.getAssistantTest());
        printVo.setVisitDate(DateUtils.formatDate(outpMr.getVisitDate(),"yyyy/MM/dd"));
        return printVo;
    }


    public static TransfusionVo convertOutpMrToTransfusionVo(TransfusionVo transfusionVo, OutpMr outpMr) {
        transfusionVo.setDiagnosis(outpMr.getDiagDesc());
        return transfusionVo;
    }

    /**
     * Description: 根据name集合做拼装
     * Param: [values]
     * return: java.lang.String
     * Author: tong-aj
     * Date: 2021/3/8
     */
    public static String getValueOfCodes(List<String> values,String splitPattern) {
        String result = "";
        StringBuilder stringBuilder = new StringBuilder();
        if(!CollectionUtils.isEmpty(values)){
            values.forEach(value->{
                stringBuilder.append(value).append(splitPattern);
            });
            result = stringBuilder.substring(0,stringBuilder.length()-1);
        }
        return result;
    }

}
